package com.example.my0609projects;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private String TAG="MianActivity";
    private Button bnt_Networking;
    private HttpUtil httpUtil;
    private ImageView img_wl;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        bnt_Networking = (Button) findViewById(R.id.bnt_Networking);
        String url="";
        httpUtil=new HttpUtil();
        img_wl=findViewById(R.id.img_wl);
        bnt_Networking.setOnClickListener(this);
        Picasso picasso=Picasso.with(this);
        RequestCreator load = picasso.load(url);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bnt_Networking:
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            String data=httpUtil.connectServer();
                            Log.e(TAG, "run: "+data );
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                    }
                }).start();

                break;
        }
    }
}
